<template>
  <div class="wrap">
    <tableSelect ref="tableSelect"  @getSelectValue="getSelectValue" :key="index">
      <div slot="head">我是插槽，写入搜索重置等功能</div>
    </tableSelect>
    <div @click="openIt">打开</div>
  </div>
</template>
<script>
import tableSelect from '@/components/tableSelect'
export default {
  data() {
    return {
      index: 0,
      columns: [
        {
          title: '生产订单',
          align: 'center',
          dataIndex: 'id',
        },
        {
          title: '生产商品',
          align: 'center',
          dataIndex: 'status_dictText',
        },
        {
          title: '计划生产数量',
          align: 'center',
          dataIndex: 'itemValue',
        },
        {
          title: '物料需求数量',
          align: 'center',
          dataIndex: 'createTime',
        },
        {
          title: '使用时间',
          align: 'center',
          dataIndex: 'useDate',
          scopedSlots: { customRender: 'useDate' },
        },
        {
          title: '所属合同',
          align: 'center',
          dataIndex: 'contractName',
          customRender: (text, record, index) => {
            return `${record.contractName}｜${record.contractCode}`
          },
        },
        {
          title: '操作',
          align: 'center',
          dataIndex: 'actions',
          scopedSlots: { customRender: 'actions' },
        },
      ],
      value: '05a2e732ce7b00aa52141ecc3e330b4e,0c9532916f5cd722017b46bc4d953e41',
      text:'admin,admin'
    }
  },
  components: { tableSelect },
  watch: {},
  created() {},
  mounted() {},
  methods: {
    openIt() {
      let par = {
        list: '/sys/dictItem/list',
        visible: true, //弹窗开启
        title: '测试标题', //标题名称
        multi: true, //是否多选
        columns: this.columns, //表格配置
        value: this.value, //需要回显的数据，如：id:'12323213,321312312,321312312'
        valueKey: 'id', //需要拿到数据的key，如：id，userId等
        text:this.text,//回显的中文，如：'张三'
        textKey:'createBy',//回显的中文key
      }
      this.$refs.tableSelect.getInit(par)
    },
    getSelectValue(id,text, item) {
      this.index += 1 //重置组件去除表格默认勾选数据，让自己赋值的数据回显（重要！！！）
      this.value = id
      this.text = text
      console.log(id,text, item, '列表选择的数据')
    },
  },
}
</script>
<style lang='less' scoped>
.wrap {
  width: 100%;
}
</style>